#=========================================================

set $mod Mod4
set $alt Mod1

set $mon1 eDP-1
set $mon2 HDMI-1

set $file  ranger
set $term --no-startup-id tilix
set $shutdown sudo -A shutdown -h now
set $reboot sudo -A reboot

# Font for window titles.
font pango:FiraCode 8

#=========================================================

# kill focused window
bindsym $mod+q kill
bindsym $alt+F4 kill

# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+c restart

# exit i3 (logs you out of your X session)
bindsym $mod+Shift+q exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"

bindsym $mod+Shift+r mode "resize"

# drag floating key
floating_modifier $alt

#=========================================================

# Natural Scrolling
exec_always --no-startup-id ~/.config/i3/set_natural_scrolling.sh &

# Polybar 
exec_always --no-startup-id ~/.config/polybar/launch.sh &
bindsym $mod+r exec ~/.config/polybar/launch.sh &
bindsym $mod+g exec killall -q polybar

# Terminal-tilix
bindsym $mod+Return exec $term

# lock
bindsym $mod+l exec --no-startup-id ~/.config/i3/lock.sh &

# Network Manager applet
exec --no-startup-id nm-applet

# Compton
exec --no-startup-id compton

# gtk theme
exec_always --no-startup-id /usr/lib/gnome-settings-daemon/gsd-xsettings

# Telegram
bindsym $mod+t  exec --no-startup-id /opt/Telegram/Telegram

# Google Chrome
bindsym $mod+w  exec google-chrome --force-dark-mode

# Firefox
bindsym $mod+f  exec firefox

#Task manager
bindsym $mod+z exec $term -e 'htop' &

# File Manager
bindsym $mod+e  exec $term -e $file &

# Bluetooth Manager
bindsym $mod+b  exec --no-startup-id blueman-manager

# Spotify
bindsym $mod+s  exec --no-startup-id spotify

# VSCode
bindsym $mod+v  exec --no-startup-id code

# Wallppaper
exec_always wal --vte -s -e -R 

# dmenu 
bindsym $mod+d exec rofi -combi-modi window#drun -show combi -modi combi -show-icons

#=========================================================

gaps inner 5
gaps outer 0

smart_borders on

bindsym $mod+i  gaps inner current plus 5
bindsym $mod+Shift+i	gaps inner current minus 5
bindsym $mod+o  gaps outer current plus 5
bindsym $mod+Shift+o    gaps outer current minus 5

# Window borders
bindsym $mod+Shift+u border none
bindsym $mod+Shift+y border pixel 3

#=========================================================

# Keyboard layout
exec --no-startup-id setxkbmap -layout us,ru && setxkbmap -option 'grp:alt_shift_toggle'

# Pulse Audio controls
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl -- set-sink-volume 0 +5% #increase sound volume
bindsym XF86AudioLowerVolume exec --no-startup-id pactl -- set-sink-volume 0 -5% #decrease sound volume
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle # mute sound

# Screen brightness controls
bindsym XF86MonBrightnessUp exec light -A 5 # increase screen brightness
bindsym XF86MonBrightnessDown exec light -U 5 # decrease screen brightness

# printscreen--scrot(Print=PrtSc/PrintScreen)
bindsym $mod+Print exec --no-startup-id xfce4-screenshooter

# tap to click disabled
exec synclient TapButton1=0 TapButton2=0 TapButton3=0

#=========================================================
#=========================================================
#=========================================================
#=========================================================
#=========================================================

# change focus
bindsym $mod+j focus left
bindsym $mod+k focus down
bindsym $mod+p focus up
bindsym $mod+semicolon focus right
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

# move focused window
bindsym $mod+Shift+j move left
bindsym $mod+Shift+k move down
bindsym $mod+Shift+l move up
bindsym $mod+Shift+colon move right
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right

#=========================================================

# split in vertical/horizontal orientation
bindsym $mod+Shift+v split toggle

# enter fullscreen mode for the focused container
bindsym $mod+Shift+f fullscreen toggle

# change container layout (stacked, tabbed, toggle split)
bindsym $mod+Shift+s layout stacking
bindsym $mod+Shift+w layout tabbed
bindsym $mod+Shift+e layout toggle split

# toggle tiling / floating
bindsym $mod+Shift+space floating toggle, resize set 1280 720, move position center

workspace_auto_back_and_forth yes

# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle

# focus the  container
bindsym $mod+Shift+a focus parent
#bindsym $mod+Shift+d focus child

#=========================================================

# Define names for default workspaces for which we configure key bindings later on.
set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"

set $firstMonitor $mon1
set $secondMonitor $mon2

# switch to workspace
bindsym $mod+1 workspace $ws1
bindsym $mod+2 workspace $ws2
bindsym $mod+3 workspace $ws3
bindsym $mod+4 workspace $ws4
bindsym $mod+5 workspace $ws5
bindsym $mod+6 workspace $ws6
bindsym $mod+7 workspace $ws7
bindsym $mod+8 workspace $ws8
bindsym $mod+9 workspace $ws9
bindsym $mod+0 workspace $ws10

workspace $ws1 output $firstMonitor
workspace $ws2 output $firstMonitor
workspace $ws3 output $firstMonitor
workspace $ws4 output $firstMonitor
workspace $ws5 output $firstMonitor
workspace $ws6 output $secondMonitor
workspace $ws7 output $secondMonitor
workspace $ws8 output $secondMonitor
workspace $ws9 output $secondMonitor
workspace $ws10 output $secondMonitor

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $ws1
bindsym $mod+Shift+2 move container to workspace $ws2
bindsym $mod+Shift+3 move container to workspace $ws3
bindsym $mod+Shift+4 move container to workspace $ws4
bindsym $mod+Shift+5 move container to workspace $ws5
bindsym $mod+Shift+6 move container to workspace $ws6
bindsym $mod+Shift+7 move container to workspace $ws7
bindsym $mod+Shift+8 move container to workspace $ws8
bindsym $mod+Shift+9 move container to workspace $ws9
bindsym $mod+Shift+0 move container to workspace $ws10

#---Workspace Bindings---# #
bindsym $mod+Home		workspace $ws1
bindsym $mod+Shift+Home		move container to workspace $ws1
bindsym $mod+End		workspace $ws10
bindsym $mod+Shift+End		move container to workspace $ws10
bindsym $mod+Prior		workspace prev
bindsym $mod+Shift+Prior	move container to workspace prev
bindsym $mod+Next		workspace next
bindsym $mod+Shift+Next		move container to workspace next
bindsym $mod+Tab		workspace back_and_forth
bindsym $mod+XF86Back		workspace prev
bindsym $mod+Shift+XF86Back	move container to workspace prev
bindsym $mod+XF86Forward	workspace next
bindsym $mod+Shift+XF86Forward	move container to workspace next
bindsym $mod+apostrophe		split horizontal ;; exec $term
bindsym $mod+slash		split vertical ;; exec $term
bindsym $mod+Shift+slash	kill
bindsym $mod+backslash		workspace back_and_forth

#=========================================================

# resize window (you can also use the mouse for that)
mode "resize" {

        # bindings
        bindsym Left resize shrink width 10 px or 10 ppt
        bindsym Down resize grow height 10 px or 10 ppt
        bindsym Up resize shrink height 10 px or 10 ppt
        bindsym Right resize grow width 10 px or 10 ppt

        bindsym j resize shrink width 10 px or 10 ppt
        bindsym k resize grow height 10 px or 10 ppt
        bindsym l resize shrink height 10 px or 10 ppt
        bindsym semicolon resize grow width 10 px or 10 ppt

        # back to normal: Enter or Escape
        bindsym Return mode "default"
        bindsym Escape mode "default"
}

#=========================================================

#------------#
# APPEARANCE #
#------------#

for_window [class="^.*"] border pixel 0

set_from_resource $fg i3wm.foreground #f0f0f0
set_from_resource $bg i3wm.background #f0f0f0
set_from_resource $lw i3wm.color12 #f0f0f0
set_from_resource $nr i3wm.color10 #f0f0f0
set_from_resource $ur i3wm.color13 #f0f0f0

# class                 border  backgr. text indicator child_border
client.focused          $bg     $bg     $fg  $fg       $fg
client.focused_inactive $bg     $bg     $fg  $bg       $bg
client.unfocused        $bg     $bg     $fg  $bg       $bg
client.urgent           $bg     $bg     $fg  $bg       $ur
client.placeholder      $bg     $bg     $fg  $bg       $fg
client.background       $bg

#=========================================================
